home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareworld 5
/
Shareworld 5 (Disk 1 of 2).adf
/
OpenWindow
/
OpenWindow.Example1
next >
Wrap
Text File
|
1995-08-29
|
3KB
|
95 lines
;Open window, public domain
;Published with Share-world 5
;-- Exec --
Openlib = -552
Closelib = -414
;-- Intuition --
Openwindow = -204
Closewindow = -72
;Program
Start
move.l 4,a6 ;Get exec lib base
move.l #iname,a1 ;library name
move.l #0,d0 ;any version
jsr Openlib(a6) ;open
cmp.l #0,d0 ;d0 will be zero if lib no open
beq error ;check for error, if error go to error
move.l d0,ibase ;store base
move.l ibase,a6 ;could change to move.l d0,a6
move.l #Window,a0 ;a0 now holds a pointer to the Window
;Definition Table
jsr Openwindow(a6)
cmp.l #0,d0 ;D0 will be zero if the window has failed to open
beq error ;Did it open?
move.l d0,windowhd ;Store that handle
bsr delay ;Branch to the delay subroutine
;Delays can also be created by using any of
;Auckland's public transport
error
move.l ibase,a6 ;It's that ibase character again!
;Note that if ibase wasn't opened then a6 will
;hold a zero, this will cause an error when
;we try to close the window (because we don't
;have the correct base pointer). This is
;okay because if the library wasn't opened
;then the window wouldn't of opened either
;Clever eh!
move.l windowhd,a0 ;Get handle of window (so computer nos what
;window to close)
cmp.l #0,a0 ;did the window open in first place?
;(windowhd zero if it didn't)
beq nowindow ;don't close if zero
jsr Closewindow(a6) ;Closing due to renovations
nowindow
move.l 4,a6 ;get exec base
;Note:You should close the libraries last.
move.l ibase,a1 ;library base for closing
cmp.l #0,a1 ;did library open
beq noi
jsr Closelib(a6) ;Let's close this thing once and for all
noi
moveq #0,d0 ;Extra bit not mention in article, tell Cli no
;error, 0 okay, 20 failure
rts ;exit to CLI, or assembler
delay
move.l #0,d0 ;clear d0 (start counting from zero)
dl1
add.l #1,d0
cmp.l #3000000,d0 ;lasts for about 4-5 secs of my A1200
bne dl1 ;Are we there yet?
rts ;Yes!
;variables
ibase dc.l 0 ;storage for ibase
windowhd dc.l 0 ;storage for window's handle
;Window Definition
Window
dc.w 10,30 ;x-y position
dc.w 200,200 ;width-height
dc.b 1,2 ;colours
dc.l $200 ;'flags' for messages (next issue!)
dc.l $100f ;'flags' for appareance (next issue!!)
;Change to $1800 for no border!
dc.l 0,0 ;gadgets, checkmark
dc.l WinName ;pointer to window name
dc.l 0 ;screen pointer (don't matter/using workbench)
dc.l 0 ;No bitmap (for fancy windows only!)
dc.w 100,100 ;smallest width-height
dc.w 600,250 ;largest width-height
dc.w 1 ;workbench window
;strings
iname dc.b 'intuition.library',0
WinName
dc.b 'My Window likes Led Zep',0 ;Do you?